# Based on Arch's PKGBUILD

_realname=tklib
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=0.6
pkgrel=5
pkgdesc="A companion to Tcllib, for Tk related packages (mingw-w64)"
arch=('any')
url='https://core.tcl.tk/tklib/home'
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-tk" "${MINGW_PACKAGE_PREFIX}-tcllib")
source=("https://github.com/tcltk/tklib/archive/tklib_${pkgver/./_}.tar.gz"
        001-posix-layout.patch)
sha256sums=('84a704f44a6956008373278a115e4b104191f0bffd2e729341edcf445e6498ac'
            'eb19f2d78d3fcfc655bc5b691ad7894fa8a0c267d7b5d73efa58746d32398a0e')

prepare() {
  cd tklib-tklib_${pkgver/./_}
  patch -p1 -i ${srcdir}/001-posix-layout.patch
}

build() {
  cd ${srcdir}/tklib-tklib_${pkgver/./_}
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}
  make all
}

package() {
  cd ${srcdir}/tklib-tklib_${pkgver/./_}
  make DESTDIR="${pkgdir}" install
  mkdir -p ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/
  cp license.terms ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
